import random
from sympy import symbols,diff
a,x = symbols("a x")
y = x ** 2
r = diff(y,x)
x_val = random.randint(-10,10)
learning_rate = 1e-3
iter = 1000
for i in range(iter):
    x_val -= r.subs(x,x_val) * learning_rate
result_y = int(y.subs(x,x_val))
x_val = int(x_val)
print(f"x_val:{x_val},x为0时y的值:{result_y}")